package cn.hackcloud.javabase.singleton;

/**
 * 单列模式 懒汉式
 * 
 * @author hackcloud
 *
 */
public class TestSingleton1 {
	public static void main(String[] args) {
		Singleton1 singleton = Singleton1.getInstance();
		Singleton1 singleton2 = Singleton1.getInstance();
		System.err.println(singleton == singleton2);
	}
}

class Singleton1 {
	private Singleton1() {
	}

	private static Singleton1 instacne;

	public static Singleton1 getInstance() {
		if (instacne == null) {
			instacne = new Singleton1();
		}
		return instacne;
	}
}
